package com.example.com.daervideo.activitys.users;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.example.com.daervideo.R;
import com.example.com.daervideo.fragments.RecordFragment;
import com.example.com.daervideo.fragments.TabContentFragment;

import java.util.ArrayList;

/**
 * Created by i7-1 on 2018/12/7.
 */

public class MoneyRecordActivity extends AppCompatActivity {
    private String[] tabIndicators = {"转入", "转出"};
    private ViewPager uViewpager;
    private ArrayList<Object> tabFragments;
    private int index;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_money_record);
        initView();
        inittab();

    }

    private void initView() {
        TextView view = (TextView) findViewById(R.id.name);
        Bundle bundle = getIntent().getBundleExtra("bundle");
        index = bundle.getInt("index");
        if (index == 1) {
            view.setText("人民币");
        } else {
            view.setText("收益火票");
        }
        uViewpager = findViewById(R.id.u_viewpager);

        tabFragments = new ArrayList<>();
        for (String s : tabIndicators) {
            tabFragments.add(RecordFragment.newInstance(s));
        }
    }

    private void inittab() {
        TabLayout uTab = findViewById(R.id.m_tab);
        uTab.setTabMode(TabLayout.MODE_FIXED);
        uTab.setSelectedTabIndicatorHeight(4);
        uTab.setSelectedTabIndicatorColor(Color.WHITE);
        ViewCompat.setElevation(uTab, 10);
        uTab.setupWithViewPager(uViewpager);
        for (int i = 0; i < tabIndicators.length; i++) {
            TabLayout.Tab itemTab = uTab.getTabAt(i);
            if (itemTab != null) {
                itemTab.setCustomView(R.layout.item_tab_layout_custom);
                TextView itemTv = (TextView) itemTab.getCustomView().findViewById(R.id.tv_menu_item);
                itemTv.setText(tabIndicators[i]);
            }
        }
        uTab.getTabAt(0).getCustomView().setSelected(true);

    }
}
